<!--
 * @Description: 邀请明细
 * @Author: liyujie
 * @Date: 2021/09/11
 * @Last Modified by: liyujie
 * @Last Modified time: 2021/09/11
-->
<template>
    <section class="wrapper">
        <div class="content-wrapper">
            <!-- header -->
            <div class="header">
                <div class="header-title">
                    邀请明细
                </div>
                <div class="tab-view">
                    <div
                        v-for="item in tabList"
                        :key="item.id"
                        class="tab-item"
                        :class="{'active': active === item.id}"
                        @click="handleTabClick(item.id)"
                    >
                        {{ item.name }}
                    </div>
                </div>
            </div>
            <!-- /header -->
            <!-- 新版本 -->
            <InviteFriendsList v-if="active === 1"/>
            <!-- 旧版本 -->
            <InviteFriendsListOld v-if="active === 2"/>
        </div>
    </section>
</template>

<script>
import {back} from '@/mixin/back';
import InviteFriendsList from "./invite-friends-list";
import InviteFriendsListOld from "./invite-friends-list-old";

export default {
    name: 'Index',
    mixins: [back],
    components: {
        InviteFriendsList,
        InviteFriendsListOld
    },
    data() {
        return {
            active: 1,
            tabList: [
                {id: 1, name: '新版本'},
                {id: 2, name: '旧版本'}
            ],
        };
    },
    mounted() {
        let query = this.$route.query;

        this.$store.commit('SET_HEADER', [{title: "APP后台"}, {title: '工作'}, {title: ' 邀请好友'}, {title: '邀请明细'}]);
        this.active = query.active ? Number(query.active) : 1;
    },
    methods: {
        handleTabClick(active) {
            this.active = active;
            this.$router.push({
                query: {
                    active,
                },
            });
        },

        /**
         * 路由跳转
         * @param routeName
         * @param query
         */
        handleRoute(routeName, query) {
            this.$router.push({
                name: routeName,
                query
            });
        },
    }
};
</script>

<style lang="less" scoped>
.wrapper {
    width: 100%;
    overflow: hidden;
    .content-wrapper {
        display: flex;
        height: calc(100% - 24px);
        flex-direction: column;
        position: relative;
        margin: 12px;
        background: #fff;
        box-sizing: border-box;

        .header {
            height: 68px;
            display: flex;
            align-items: center;
            border-bottom: 1px solid #F0F2F5;
            padding: 0 35px;
            flex-shrink: 0;
            .header-title {
                font-size: 20px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                color: #333333;
                line-height: 20px;
                position: relative;
                margin-right: 12px;

                &::before {
                    content: '';
                    position: absolute;
                    width: 3px;
                    height: 20px;
                    background: #1890FF;
                    left: -8px;
                    top: 50%;
                    transform: translateY(-50%);
                }
            }

            .tab-view {
                display: flex;
                margin-left: 20px;

                .tab-item {
                    height: 30px;
                    padding: 8px 12px;
                    background: #FFFFFF;
                    border-radius: 4px;
                    border: 1px solid #F0F2F5;
                    font-size: 14px;
                    font-family: PingFangSC-Medium, PingFang SC;
                    font-weight: 500;
                    color: #999999;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    margin-right: 32px;
                    cursor: pointer;
                    transition: all .2s;

                    &.active {
                        background: #20A0FF;
                        color: #fff;
                    }
                }
            }
        }
    }
}
</style>


